Replace test-gcc-flag with Linux-style cc-option.
authorkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Wed, 18 Oct 2006 18:14:34 +0000 (19:14 +0100)
committerkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Wed, 18 Oct 2006 18:14:34 +0000 (19:14 +0100)
Improve on Linux implementation by looking for any output
on stdout/stderr. This indicates badness.

Signed-off-by: Keir Fraser <keir@xensource.com>
Config.mk
tools/firmware/hvmloader/Makefile
tools/firmware/vmxassist/Makefile
tools/ioemu/Makefile.target
xen/arch/x86/Rules.mk

index e626a26283c031aea5b7d321a00e323d4d8e0949..4cd113d905bdc54ebf974044ed92126742cff8d6 100644 (file)
--- a/Config.mk
+++ b/Config.mk
@@ -26,7 +26,10 @@ EXTRA_INCLUDES += $(EXTRA_PREFIX)/include
 EXTRA_LIB += $(EXTRA_PREFIX)/$(LIBDIR)
 endif
 
-test-gcc-flag = $(shell $(1) -v --help 2>&1 | grep " $(2) " >/dev/null 2>&1 && echo $(2))
+# cc-option
+# Usage: cflags-y += $(call cc-option,$(CC),-march=winchip-c6,-march=i586)
+cc-option = $(shell if test -z "`$(1) $(2) -S -o /dev/null -xc \
+              /dev/null 2>&1`"; then echo "$(2)"; else echo "$(3)"; fi ;)
 
 ifneq ($(debug),y)
 CFLAGS += -DNDEBUG
@@ -42,8 +45,8 @@ CFLAGS += -Wall -Wstrict-prototypes
 # result of any casted expression causes a warning.
 CFLAGS += -Wno-unused-value
 
-HOSTCFLAGS += $(call test-gcc-flag,$(HOSTCC),-Wdeclaration-after-statement)
-CFLAGS     += $(call test-gcc-flag,$(CC),-Wdeclaration-after-statement)
+HOSTCFLAGS += $(call cc-option,$(HOSTCC),-Wdeclaration-after-statement,)
+CFLAGS     += $(call cc-option,$(CC),-Wdeclaration-after-statement,)
 
 LDFLAGS += $(foreach i, $(EXTRA_LIB), -L$(i)) 
 CFLAGS += $(foreach i, $(EXTRA_INCLUDES), -I$(i))
index ae031e96d497a300be02bd0d6aa4543f0dbfeebd..cb740a7d557ef9d0c99192c5a2a082ee42338636 100644 (file)
@@ -32,9 +32,9 @@ DEFINES  =-DDEBUG
 XENINC   =-I$(XEN_ROOT)/tools/libxc
 
 # Disable PIE/SSP if GCC supports them. They can break us.
-CFLAGS  += $(call test-gcc-flag,$(CC),-nopie)
-CFLAGS  += $(call test-gcc-flag,$(CC),-fno-stack-protector)
-CFLAGS  += $(call test-gcc-flag,$(CC),-fno-stack-protector-all)
+CFLAGS  += $(call cc-option,$(CC),-nopie,)
+CFLAGS  += $(call cc-option,$(CC),-fno-stack-protector,)
+CFLAGS  += $(call cc-option,$(CC),-fno-stack-protector-all,)
 
 OBJCOPY  = objcopy
 CFLAGS  += $(DEFINES) -I. $(XENINC) -fno-builtin -O2 -msoft-float
index 1f441a12c38c3d8c04dfc253e88c56a2e27eb1b7..70f7a0e0a3ab00a93c70309745771c914d3e8237 100644 (file)
@@ -32,9 +32,9 @@ DEFINES=-DDEBUG -DTEXTADDR=$(TEXTADDR)
 XENINC=-I$(XEN_ROOT)/tools/libxc
 
 # Disable PIE/SSP if GCC supports them. They can break us.
-CFLAGS  += $(call test-gcc-flag,$(CC),-nopie)
-CFLAGS  += $(call test-gcc-flag,$(CC),-fno-stack-protector)
-CFLAGS  += $(call test-gcc-flag,$(CC),-fno-stack-protector-all)
+CFLAGS  += $(call cc-option,$(CC),-nopie,)
+CFLAGS  += $(call cc-option,$(CC),-fno-stack-protector,)
+CFLAGS  += $(call cc-option,$(CC),-fno-stack-protector-all,)
 
 CPP      = cpp -P
 OBJCOPY  = objcopy -p -O binary -R .note -R .comment -R .bss -S --gap-fill=0
index b216e6acaf63343589553fc25457101db9be2513..c80cb586c491d71b6265a48aa252a5dadc0557f0 100644 (file)
@@ -23,7 +23,7 @@ VPATH+=:$(SRC_PATH)/linux-user
 DEFINES+=-I$(SRC_PATH)/linux-user -I$(SRC_PATH)/linux-user/$(TARGET_ARCH)
 endif
 CFLAGS+=-Wall -O2 -g -fno-strict-aliasing
-SSE2 := $(call test-gcc-flag,$(CC),-msse2)
+SSE2 := $(call cc-option,$(CC),-msse2,)
 ifeq ($(SSE2),-msse2)
 CFLAGS += -DUSE_SSE2=1 -msse2
 endif
index 33eb5b53a4e945aaf6051995d23bb1c62c63f2df..fd1a52e365e76a1258f8116a3ec7186d1a2c1c90 100644 (file)
@@ -11,26 +11,26 @@ HAS_VGA  := y
 pae ?= n
 supervisor_mode_kernel ?= n
 
-CFLAGS  += -nostdinc -fno-builtin -fno-common -fno-strict-aliasing
-CFLAGS  += -iwithprefix include -Werror -Wno-pointer-arith -pipe
-CFLAGS  += -I$(BASEDIR)/include 
-CFLAGS  += -I$(BASEDIR)/include/asm-x86/mach-generic
-CFLAGS  += -I$(BASEDIR)/include/asm-x86/mach-default
+CFLAGS += -nostdinc -fno-builtin -fno-common -fno-strict-aliasing
+CFLAGS += -iwithprefix include -Werror -Wno-pointer-arith -pipe
+CFLAGS += -I$(BASEDIR)/include 
+CFLAGS += -I$(BASEDIR)/include/asm-x86/mach-generic
+CFLAGS += -I$(BASEDIR)/include/asm-x86/mach-default
 
 # Prevent floating-point variables from creeping into Xen.
-CFLAGS  += -msoft-float
+CFLAGS += -msoft-float
 
 # Disable PIE/SSP if GCC supports them. They can break us.
-CFLAGS  += $(call test-gcc-flag,$(CC),-nopie)
-CFLAGS  += $(call test-gcc-flag,$(CC),-fno-stack-protector)
-CFLAGS  += $(call test-gcc-flag,$(CC),-fno-stack-protector-all)
+CFLAGS += $(call cc-option,$(CC),-nopie,)
+CFLAGS += $(call cc-option,$(CC),-fno-stack-protector,)
+CFLAGS += $(call cc-option,$(CC),-fno-stack-protector-all,)
 
 ifeq ($(TARGET_SUBARCH)$(pae),x86_32y)
-CFLAGS  += -DCONFIG_X86_PAE=1
+CFLAGS += -DCONFIG_X86_PAE=1
 endif
 
 ifeq ($(supervisor_mode_kernel),y)
-CFLAGS  += -DCONFIG_X86_SUPERVISOR_MODE_KERNEL=1
+CFLAGS += -DCONFIG_X86_SUPERVISOR_MODE_KERNEL=1
 endif
 
 ifeq ($(XEN_TARGET_ARCH),x86_32)
@@ -39,11 +39,11 @@ x86_64 := n
 endif
 
 ifeq ($(TARGET_SUBARCH),x86_64)
-CFLAGS  += -mno-red-zone -fpic -fno-reorder-blocks
-CFLAGS  += -fno-asynchronous-unwind-tables
+CFLAGS += -mno-red-zone -fpic -fno-reorder-blocks
+CFLAGS += -fno-asynchronous-unwind-tables
 # -fvisibility=hidden reduces -fpic cost, if it's available
-CFLAGS  += $(shell $(CC) -v --help 2>&1 | grep " -fvisibility=" | \
-             grep -q hidden && echo "-DGCC_HAS_VISIBILITY_ATTRIBUTE")
+CFLAGS += $(call cc-option,$(CC),-fvisibility=hidden,)
+CFLAGS := $(subst -fvisibility=hidden,-DGCC_HAS_VISIBILITY_ATTRIBUTE,$(CFLAGS))
 x86_32 := n
 x86_64 := y
 endif